import 'package:flutter/material.dart';

Future<bool?> zdyConfirm({
  required BuildContext context,
  String title = "是否确定",
  String content = "",
  VoidCallback? onOKPressed,
  VoidCallback? onCancelPressed,
  String confirmText = '确定',
  String cancelText = '取消',
}) async {
  return await showDialog<bool>(
    context: context,
    barrierDismissible: false,
    builder: (BuildContext context) {
      return AlertDialog(
        title: Text(title),
        content: SingleChildScrollView(
          child: Text(content),
        ),
        actions: <Widget>[
          TextButton(
            child: Text(cancelText),
            onPressed: () {
              onCancelPressed?.call();
              Navigator.of(context).pop(false);
            },
          ),
          TextButton(
            child: Text(confirmText),
            onPressed: () {
              onOKPressed?.call();
              Navigator.of(context).pop(true);
            },
          ),
        ],
      );
    },
  );
}
